<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/salesReport.do?action=cobacklogreport" />
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    String userTypeCustomer = Constants.USER_TYPE_CUSTOMER + "";
    String userTypeSalesPerson = Constants.USER_TYPE_SALES_PERSON + "";
%>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>
<script>
var dateElement = "";
    function openCalendar(dateValue){
		dateElement = dateValue;
	  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  		newWindow.moveTo(550,180);
	  	newWindow.focus();
    }
	function assignDate(passedValue)
    {
		dateElement.value=passedValue;
		window.focus();
    }
function Disab() {
	len=document.backlogReport.category.length
	for(var i=0; i<len; i++){

		if(document.backlogReport.category[i].checked)
		{
			var temp = document.backlogReport.category[i].value;

			if(temp == 'salesOrder' || temp == 'partNumber' ){
				for(var j = 0; j<document.backlogReport.byperiod.length; j++){
					document.backlogReport.byperiod[j].disabled = true;
				}
			}
		}

	}
}

function enablePeriod(){
	for(var j = 0; j<document.backlogReport.byperiod.length; j++){
		document.backlogReport.byperiod[j].disabled = false;
	}

}

function dateCheck()
{
	var date_check = document.wipInventoryInfo.asOfDate.value;
	var pa = document.getElementById("errors");
	if (date_check=='')
		date_check='0';
	else
	{
		var month, date, year;
		var m;
		var day_check  = date_check.split('/');
		month = day_check[0];
		date = day_check[1];
		year = day_check[2];
		if ( month < 10 )
		{
			if ( month.length == 1 )
				month = "0"+month;
		}

		if ( date < 10 )
		{
			if (date.length == 1)
				date = "0"+date;
		}
		date_check = month+"/"+date+"/"+year;
	}

	var check = date_check.split('/');
	if ( check[0] == '00' )
		date_check = '0';
	if ( date_check!='0' )
	{
		if ( !isDate( year, month, date ) )
		{
			pa.innerHTML="Please enter a valid Date...!";
			date_check = 'InValid';
		}
	}
	return date_check;
}

function dateRange(fileType){
	var pa = document.getElementById("errors");
    formdoc = document.backlogReport;
    if(chkDate(formdoc.asOfDate.value,'As Of Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.asOfDate.focus();
        return false;
    }
	var d = new Date();
	var day = d.getDate();
	var month = d.getMonth()+1;
	var year = d.getFullYear();
	var hour = d.getHours();
	var min = d.getMinutes();
	var sec = d.getSeconds();

    if ( month < 10 )
	    month = "0"+month;
	if ( day < 10 )
	    day = "0"+day;

    var today = month+"/"+day+"/"+year;

	var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

    if( document.backlogReport.asOfDate.value != '' )
    {
        var array = (document.backlogReport.asOfDate.value).split("/");
        if ( array[0] < 10 && array[0].length < 2)
            array[0] = "0"+array[0];
        if ( array[1] < 10 && array[1].length < 2 )
            array[1] = "0"+array[1];
        document.backlogReport.asOfDate.value = array[0]+"/"+array[1]+"/"+array[2];
    }

    var partNumberObj = document.backlogReport.product;
    var processstepId = "";
    var count = 0;
    for( var i = 0; i < partNumberObj.length; i++ )
    {
        if( partNumberObj.options[i].selected )
        {
            count++;
            if ( processstepId != '' )
            {
                processstepId = processstepId + "," + partNumberObj.options[i].value;
            }
            else
            {
                processstepId = partNumberObj.options[i].value;
                if( partNumberObj.options[i].value == '0' )
                {
                    break;
                }
            }
        }
    }
    if ( processstepId == '')
    {
        processstepId = "0";
    }
    if( count > 10)
    {
        pa.innerHTML = "<li>Please select upto 10 Products only";
        return;
    }
    else
    {
        document.backlogReport.prompt0.value = processstepId;
    }

    /*var customerObj = document.backlogReport.customer;
    var customerId = "";
    var counter = 0;
    for( var i = 0; i < customerObj.length; i++ )
    {
        if( customerObj.options[i].selected )
        {
            count++;
            if ( customerId != '' )
            {
                customerId = customerId + "," + customerObj.options[i].value;
            }
            else
            {
                customerId = customerObj.options[i].value;
                if( customerObj.options[i].value == '0' )
                {
                    break;
                }
            }
        }
    }
    if ( customerId == '')
    {
        customerId = "0";
    }
    if( counter > 10)
    {
        pa.innerHTML = "<li>Please select upto 10 Customers only";
        return;
    }
    else
    {
        document.backlogReport.prompt2.value = customerId;
    }*/

    if(document.backlogReport.salesorderno.value=='')
		document.backlogReport.prompt1.value='0';
	else
		document.backlogReport.prompt1.value=document.backlogReport.salesorderno.value;

   if(document.backlogReport.customer.value=='')
		document.backlogReport.prompt2.value='0';
	else
		document.backlogReport.prompt2.value=document.backlogReport.customer.value;

    <%--<logic:equal value="<%=userTypeCustomer%>" name="user" property="userType" scope="session">
    if  ( document.backlogReport.prompt2.value== 0 )
    {
        var element = document.backlogReport.customer;
        var customerIds = "0";
        for( var i = 0 ; i < element.length; i++ )
        {
            if ( customerIds != '' && customerIds != "0" )
            {
                customerIds = customerIds+","+element.options[i].value;
            }
            else
            {
                customerIds = element.options[i].value;
            }
        }

        document.backlogReport.prompt2.value= customerIds;
    }
    </logic:equal>--%>

    <logic:equal value="<%=userTypeSalesPerson%>" name="user" property="userType" scope="session">
    if  ( document.backlogReport.prompt2.value== 0 )
    {
        var element = document.backlogReport.customer;
        var customerIds = "0";
        for( var i = 0 ; i < element.length; i++ )
        {
            if ( customerIds != '' && customerIds != "0" )
            {
                customerIds = customerIds+","+element.options[i].value;
            }
            else
            {
                customerIds = element.options[i].value;
            }
        }

        document.backlogReport.prompt2.value= customerIds;
    }
    </logic:equal>

     if(document.backlogReport.salesPerson.value=='')
		document.backlogReport.prompt3.value='0';
	else
		document.backlogReport.prompt3.value = document.backlogReport.salesPerson.value;
    <logic:notEqual value="<%=userTypeCustomer%>" name="user" property="userType" scope="session">
    if  ( document.backlogReport.salesPerson.value== 0 )
    {
        var element = document.backlogReport.salesPerson;
        var customerIds = "0";
        for( var i = 0 ; i < element.length; i++ )
        {
            if ( customerIds != '' && customerIds != "0" )
            {
                customerIds = customerIds+","+element.options[i].value;
            }
            else
            {
                customerIds = element.options[i].value;
            }
        }
    }
    </logic:notEqual>

    if(document.backlogReport.asOfDate.value=='')
		document.backlogReport.prompt4.value='0';
	else
		document.backlogReport.prompt4.value = document.backlogReport.asOfDate.value;

    //alert ( document.backlogReport.prompt4.value );

   	var type="";
	var cat="";
	var period="";

	for (counter = 0; counter < backlogReport.type.length; counter++)
	{
		if (backlogReport.type[counter].checked){
			type = backlogReport.type[counter].value;
		}
	}

	for (counter = 0; counter < backlogReport.category.length; counter++)
	{
		if (backlogReport.category[counter].checked){
			cat = backlogReport.category[counter].value;
		}
	}

	for (counter = 0; counter < backlogReport.byperiod.length; counter++)
	{
		if (backlogReport.byperiod[counter].checked){
			period = backlogReport.byperiod[counter].value;
		}
	}

   if(document.backlogReport.region.value=='')
		document.backlogReport.prompt11.value='0';
	else
		document.backlogReport.prompt11.value=document.backlogReport.region.value;

    if (document.backlogReport.endUser.value == '')
	document.backlogReport.prompt12.value = '0';
    else
	document.backlogReport.prompt12.value = document.backlogReport.endUser.value;

	document.backlogReport.prompt5.value = type;
	document.backlogReport.prompt7.value = cat;
    document.backlogReport.prompt6.value = document.backlogReport.orderType.value;
    document.backlogReport.prompt8.value = defaultPrompt;
    document.backlogReport.prompt9.value = period;
    document.backlogReport.prompt10.value = "crystal";

    if ( cat =="partNumber" )
    {
        document.backlogReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Backlog/Backlog_PartNumber_Report.rpt";
    }
    else if ( cat == "salesOrder")
    {
        document.backlogReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Backlog/Backlog_SalesOrder_Report.rpt";
    }
    else
    {
        document.backlogReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Backlog/Backlog_Report.rpt";
    }
    /*if( success == true )
    {*/
        if( fileType == 2 )
        {
            var prompt0 = document.backlogReport.prompt0.value;
            var prompt1 = document.backlogReport.prompt1.value;
            var prompt2 = document.backlogReport.prompt2.value;
            var prompt3 = document.backlogReport.prompt3.value;
            var prompt4 = document.backlogReport.prompt4.value;
            var prompt5 = document.backlogReport.prompt5.value;
            var prompt6 = document.backlogReport.prompt6.value;
            var prompt7 = document.backlogReport.prompt7.value;
            var prompt8 = document.backlogReport.prompt8.value;
            var prompt9 = period;
            var prompt11 = document.backlogReport.prompt11.value;
            var prompt10 = "XLREPORT";
            var prompt12 = document.backlogReport.prompt12.value;
            var newWindow;
            var url = '<%=chipTracContext%>/customerReport.do?action=cobacklogxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11+ '&prompt12=' + prompt12;
            newWindow = window.open ( url, 'CustomerReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else
        {
            document.backlogReport.submit();
        }
    }
/*}*/

function installNPViewer()
{
    var url = '<%=chipTracContext%>/jsp/includes/others/npviewer.exe';
    newWindow = window.open ( url, 'InstallNPViewer', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=50,height=50,resizable=no');
}

</script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<form name =backlogReport method="post">
<input type="hidden" name="prompt0">
<input type="hidden" name="prompt1">
<input type="hidden" name="prompt2">
<input type="hidden" name="prompt3">
<input type="hidden" name="prompt4">
<input type="hidden" name="prompt5">
<input type="hidden" name="prompt6">
<input type="hidden" name="prompt7">
<input type="hidden" name="prompt8">
<input type="hidden" name="prompt9">
<input type="hidden" name="prompt10">
<input type="hidden" name="prompt11">
<input type="hidden" name="prompt12">

<!-- Top Header Start-->

    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%--<%@ include file="/jsp/sales/sales_report_menu.jsp" %>--%>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/sales/sales_report_menu.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/sales/external_reports_menu.jsp" %>
    </logic:notEqual>
<!-- end of the side navigations -->
<!-- This was just for test-->
<TD bgcolor="#ffffff">
<IMG height=9 src="images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<center><span class="NArialW">Backlog Reports&nbsp;&nbsp;</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>

 <table border="0" width="90%" align=right cellspacing="4" cellpadding="2" >

    <tr><td colspan=6 align="left" class='NArialL'><b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font></b></td></tr>
    <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
	<tr>
      <td width="17%" valign="top"><font class="NArialL">Customer :</font></td>
      <td width="20%" valign="top"><font class="NArialL">
      	<select size="1" name="customer" class="txfield" style= "width:170px">
            <!--<option value="0">All Customers</option>-->
                <logic:iterate id="customerSelectList" name="customerSelectList">
	                <logic:notEqual name="customerSelectList" value="null">
                        <option value = <bean:write name="customerSelectList" property="value"/>>
                            <bean:write name="customerSelectList" property="label"/>
                        </option>
                    </logic:notEqual>
                </logic:iterate>
        </select>
        </font>
      </td>

      <td width="5%">&nbsp;</td>
      <td width="17%" valign="top" nowrap>
	    <font class="NArialL"><bean:message key="label.mfgPartNumber" /> :</font>
	  </td>
      <td width="20%" valign="top"><font class="NArialL">
	    <select size="5" name="product" class="txfield" style="width:170px" multiple="true">
            <option value="0" selected>All Products</option>
                <logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList">
	                    <logic:notEqual name="mktgPartNumberSelectList" value="null">
                            <option value = "<bean:write name="mktgPartNumberSelectList" property="productId"/>">
                                <bean:write name="mktgPartNumberSelectList" property="manufacturingPartNo"/>
                            </option>
                        </logic:notEqual>
                </logic:iterate>
        </select>
        </font>
      </td>
	  <td width="10%">&nbsp;</td>
    </tr>

	<tr>
      <td width="17%"><font class="NArialL">Sales Order No :</font></td>
      <td width="20%"><font class="NArialL">
          <input type="text" name="salesorderno" class="txfield" style="width:170px" ></font>
      </td>
	  <td width="5%">&nbsp;&nbsp;</td>
      <td width="17%"><font class="NArialL">Sales Person :</font></td>
      <td width="20%"><font class="NArialL"><select size="1" name="salesPerson" class="txfield" style="width:170px">
            <option value="0">All Sales Persons</option>
                <logic:iterate id="salesPersonList" name="salesPersonList">
                    <logic:notEqual name="salesPersonList" value="null">
                        <option value = "<bean:write name="salesPersonList" />">
                            <bean:write name="salesPersonList"/>
                        </option>
                    </logic:notEqual>
                </logic:iterate>
       </select>
       </font>
      </td>
	  <td width="10%">&nbsp;</td>
    </tr>
    
	<tr>
      <td width="17%"><font class="NArialL">Region: </font></td>
      <td width="20%" class="NArialL">
            <select name="region" class="txfield" style="width:170px" >
                <option value="0">All Regions</option>
                    <logic:iterate id="regionList" name="regionList">
                        <logic:notEqual name="regionList" value="null">
                            <option value = "<bean:write name="regionList" />">
                                <bean:write name="regionList"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
            </select>
		</td>
      <td width="5%">&nbsp;</td>
      <td width="15%"class="NArialL">Category :</td>
      <td width="17%"class="NArialL">
      	<select name="orderType" class="txfield" style="width:170px" >
            <option value="1" selected >Regular</option>
            <option value="0">Sample</option>
            <option value="2">Consignment</option>
        </select>
      </td>
      <td width="10%">&nbsp;</td>
    </tr>

    <tr>
      <td width="17%"><font class="NArialL">As Of Date : <%--<br> (mm/dd/yyyy)--%> </font></td>
      <td width="20%"><font class="NArialL">
      	<input type="text" name="asOfDate" size="12" class="txfield"></font>&nbsp;
            <a href="javascript:openCalendar(document.backlogReport.asOfDate)" onmouseover="window.status='Click to Select Date';return true" onMouseOut="window.status='';return true">
            <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18></a>
	  </td>
      <td width="5%">&nbsp;</td>
      <td width="15%"class="NArialL"><bean:message key="label.sales.endUser"/> : </td>
      <td width="17%"class="NArialL">
      <select name="endUser" class="txfield" style= "width:170px" >
      <option value="0">All <bean:message key="label.sales.endUser"/>s</option>
        <logic:iterate id="endUserList" name="endUserList">
            <logic:notEqual name="endUserList" value="null">
                <option value = "<bean:write name="endUserList" property="label"/>">
                    <bean:write name="endUserList" property="label"/>
                </option>
            </logic:notEqual>
        </logic:iterate>
      </select>
      </td>
      <td width="10%">&nbsp;</td>
    </tr>

	<tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

	<tr>
        <td colspan=4>
            <input type="radio" name="type" value="OPEN" onclick="javascript:enablePeriod()" checked >
                <font class="NArialL">Open Backlog</font>&nbsp;&nbsp;
            <input type="radio" name="type" value="HOLD" onclick="javascript:enablePeriod()" >
                <font class="NArialL">Hold Backlog</font>&nbsp;&nbsp;
            <input type="radio" name="type" value="ALL" onclick="javascript:enablePeriod()" >
                <font class="NArialL">All Backlogs</font><br>
        </td>
     </tr>
     <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
     <tr>
         <td colspan=6>
     	    <input type="radio" name="category" value="reqDockDate" onclick="javascript:enablePeriod()" checked>
    		    <font class="NArialL">Requested Dock Date</font>&nbsp;&nbsp;
		    <input type="radio" name="category" value="revDate" onclick="javascript:enablePeriod()">
	    	    <font class="NArialL">Revised Ship Date </font>&nbsp;&nbsp;
		    <input type="radio" name="category" value="scheduleDate" onclick="javascript:enablePeriod()">
	    	    <font class="NArialL">Schedule Ship Date </font>&nbsp;&nbsp;<br>
		    <input type="radio" name="category" value="salesOrder" onclick = "javascript:Disab()" >
	    	    <font class="NArialL">Sales Order Number </font>&nbsp;&nbsp;&nbsp;
            <input type="radio" name="category" value="partNumber" onclick = "javascript:Disab()" >
	    	    <font class="NArialL"><bean:message key="label.mfgPartNumber" /></font>&nbsp;&nbsp;
	    </td>
     </tr>
     <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
     <tr>
         <td colspan=4>
	    	<input type="radio" name="byperiod" value="byMonth" checked>
	    		<font class="NArialL">By Month </font>&nbsp;&nbsp;
	    	<input type="radio" name="byperiod" value="byQuarter">
	    		<font class="NArialL">By Quarter</font>&nbsp;&nbsp;
	    	<input type="radio" name="byperiod" value="byYear">
	    		<font class="NArialL">By Year</font>&nbsp;&nbsp;<br>
        </td>
        <td colspan=2 align="left">
            <a class="leftsection" href="javascript:dateRange(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
        </td>
     </tr>
     <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr>
      <td colspan=3 align=right><input type="image" onClick="javascript:return dateRange(1);" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true"onmouseout="window.status='';return true"title="Click here to Generate Report"/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="javascript:document.backlogReport.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
      </td>
      <td colspan=3 align="center" >
            <a class="leftsection" href="javascript:installNPViewer()" onMouseOver="window.status='Click here to install Activex Control for Reports';return true" onMouseOut="window.status='';return true" title='Click here to install Activex Control for Reports' >
                Click here to install Activex Control for Reports
            </a>
       </td>
    </tr>
 </table>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>

</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</form>
</BODY>
</HTML>